﻿using System.Globalization;

namespace max_prime_number
{
    internal class Program
    {
        /// <summary>
        /// 查找最大质数
        /// </summary>
        /// <param name="args"></param>
        const int N = 100000;
        static void Main(string[] args)
        {
            int maxpn = 2, j;
            DateTime begintime = DateTime.Now, endtime;
            for (int i = N; i > 1; i--)
            {
                for (j = i - 1; j > 1; j--)
                {
                    if (i % j == 0)
                        break;
                }
                if (j == 1)
                {
                    maxpn = i;
                    break;
                }
            }
            endtime = DateTime.Now;
            TimeSpan totaltime = endtime - begintime;
            Console.Write($"{N}以内最大质数为{maxpn},总用时为{totaltime}");
            Console.ReadKey();
        }
    }
}